<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Order_shixun extends MY_Controller {
	function __construct(){
		parent::__construct();
		$parent_id = 2;
		//获取school二级菜单
		$this->load->model('School_manage_menu_model');
	    $menu_list = $this->School_manage_menu_model->get_menu_list($this->is_manage,$parent_id);
	    // print_r($menu_list);exit;
	    $this->smarty->assign("menu_list", $menu_list);

		$this->left_menu_min = array("menu" => "交易订单", "curr" => '/order_shixun', "list" => $menu_list);
	  	$this->smarty->assign("left_menu_min", $this->left_menu_min);
	  	$this->smarty->assign("menu", 'orders');
	}

	public function index($status='all', $order_type = 5, $order_num = 0, $st = 0, $et = 0, $mobile = 0, $limit = 0){
		$this->offset = 10;
		if($this->input->post()){
			$limit = 0;
			$post_data = $this->input->post();
			$order_num = !empty($post_data['order_num']) ? urldecode($post_data['order_num']) : 0;
			$st = !empty($post_data['st']) ? $post_data['st'] : 0;
			$et = !empty($post_data['et']) ? $post_data['et'] : 0;
			$mobile = !empty($post_data['mobile']) ? $post_data['mobile'] : 0;
		}else{
			$order_num = urldecode($order_num);
			$page_config['uri_segment'] = 9;
		}
		$data = array( 'status' => $status,'order_type' => $order_type, 'order_num' => $order_num,'st' => $st,'et' => $et,'mobile' => $mobile);

		$this->load->model('Order_model');
		$result = $this->Order_model->get_order_list_by_school($limit,$this->offset,$this->user_data['school_id'],$data);
		$this->smarty->assign("order", $result['result']);
		//分页
		$this->load->library('pagination');
		$page_config['base_url'] = '/order_shixun/index/'.$data['status'].'/'.$data['order_type'].'/'.$data['order_num'].'/'.$data['st'].'/'.$data['et'].'/'.$data['mobile'];
		$page_config['total_rows'] = $result['total_count'];
		$page_config['per_page'] = $this->offset;
		$this->smarty->assign("data", $data);
		$this->pagination->initialize($page_config);
		$pagination = $this->pagination->create_links();

		$this->smarty->assign("pagination", $pagination);

		// $this->smarty->assign("menu", "orders");
		$this->smarty->display("orders/shixun.html");
	}
}